﻿using DatabaseTransfer.Connections;
using DatabaseTransfer.Tables;
using DatabaseTransfer.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DatabaseTransfer.Forms
{
    public partial class LoadFiles : Form
    {
        public LoadFiles()
        {
            InitializeComponent();
        }

        private void dbConBtn_Click(object sender, EventArgs e)
        {
            FileDialog fd = new OpenFileDialog();
            fd.Filter = "DB Transfer File(*.dtf)|*.dtf";
            fd.ShowDialog();

            dbFileName.Text = fd.FileName;
        }

        private void continueBtn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(dbFileName.Text))
            {
                MessageBox.Show("Please provide a database connection file");
                return;
            }

            DatabaseTransferSerializer dts = DatabaseTransferSerializer.Deserialize(dbFileName.Text);
            this.Dispose();

            ColumnMatcher cm = new ColumnMatcher(dts);
            cm.ShowDialog();
        }   
    }
}
